//
// Created by yinlijun on 17-10-1.
//

#ifndef ROCKYSOCKET_ROCKY_CONNECTION_H
#define ROCKYSOCKET_ROCKY_CONNECTION_H

#ifdef __cplusplus
extern "C" {
#endif

struct RockyConnection;

typedef struct RockyConnection RockyConnection;

typedef void (*on_received_data)(RockyConnection *connection, void *data, size_t data_size);

typedef void (*on_connection_disconnected)(RockyConnection *connection);


RockyConnection *rocky_connection_create(int fd, size_t buf_size, on_received_data on_received,
                                         on_connection_disconnected on_disconnected);

void rocky_connection_write_data(RockyConnection *thiz, void *data, size_t data_size);

int rocky_connection_loop(RockyConnection *thiz);

void rocky_connection_shutdown(RockyConnection *thiz);

void rocky_connection_destroy(RockyConnection *thiz);

void *rocky_connectoin_handler_callback_for_server_thread(void *arg, void *ctx);

void rocky_connection_destroy_callback_for_server_thread(void *arg, void *ctx);


#ifdef __cplusplus
}
#endif

#endif //ROCKYSOCKET_ROCKY_CONNECTION_H
